﻿using PetaPoco;
using System;
using System.ComponentModel.DataAnnotations;

namespace Qy.Models;

[TableName("qy_content")]
[PrimaryKey("Id", AutoIncrement = true)]
public class Content
{
    public int Id { get; set; }
    public int Cid { get; set; }
    public string Title { get; set; }
    public string Attments { get; set; }
    public string Examine { get; set; }
    public string Img { get; set; }
    public int Imgbl { get; set; }
    public DateTime Time { get; set; }
    public int Hits { get; set; }
    public int Uid { get; set; }
    public bool Status { get; set; }
    public bool AttA { get; set; }
    public bool AttB { get; set; }
    public bool AttC { get; set; }

}


public class EditContentAndContent
{
    public int Id { get; set; }
    [Display(Name = "栏目")]
    [Required(ErrorMessage = "请选择栏目")]
    public int Cid { get; set; }
    [Display(Name = "标题")]
    [Required(ErrorMessage = "标题未填写")]
    public string Title { get; set; }
    public string Attments { get; set; }
    [Display(Name = "作者")]
    [Required(ErrorMessage = "作者未填写")]
    public string Examine { get; set; }
    [Display(Name = "缩略图")]
    public string Img { get; set; }
    public DateTime Time { get; set; } = DateTime.Now;
    [Display(Name = "显示状态")]
    [Required(ErrorMessage = "选择内容显示状态")]
    public bool Status { get; set; }
    [Display(Name = "头条")]
    public bool AttA { get; set; }
    [Display(Name = "小头条")]
    public bool AttB { get; set; }
    [Display(Name = "轮换")]
    public bool AttC { get; set; }

    [Display(Name = "内容")]
    [Required(ErrorMessage = "内容未填写")]
    public string Content { get; set; }
    public Content AsContent()
    {
        return new Content
        {
            Id = Id,
            Cid = Cid,
            Title = Title,
            Attments = Attments,
            Examine = Examine,
            Img = Img,
            Time = Time,
            Status = Status,
            AttA = AttA,
            AttB = AttB,
            AttC = AttC
        };
    }

    public ContentContent AsContentContent()
    {
        return new ContentContent
        {
            Aid = Id,
            Content = Content
        };
    }
}


public class ViewContentAndContent
{
    public int Id { get; set; }
    public int Cid { get; set; }
    public string Title { get; set; }
    public string Attments { get; set; }
    public string Img { get; set; }
    public string Examine { get; set; }
    public int Hits { get; set; }
    public DateTime Time { get; set; }
    public int Aid { get; set; }
    public string Content { get; set; }

}

/// <summary>
/// 切换内容属性状态
/// </summary>
public class FormChange
{
    public string Title { get; set; }
    public string Name { get; set; }
    public int Id { get; set; }
    public int Val { get; set; }
}

/// <summary>
/// 查询模型
/// </summary>
public class ContentQuery : Page<ViewContentAndCate>
{
    public string Cid { get; set; } = "0";
    public int Limit { get; set; } = 15;
    public int Page { get; set; } = 1;
    public string CacheName { get; set; }
    public int CacheTime { get; set; }
    public int Att { get; set; }
    public bool ImgBl { get; set; }
    public string Orderby { get; set; }
    public int Status { get; set; } = 2;
    public int Uid { get; set; }
    public string Title { get; set; }
    public string Uids { get; set; }
}

/// <summary>
/// 查询模型
/// </summary>
public class ContentCount
{
    public string Name { get; set; }
    public int Value { get; set; }
    public int Status { get; set; }
}
/// <summary>
/// 统计模型
/// </summary>
public class NumCount
{
    public long Content { get; set; }
    public long User { get; set; }
    public long Log { get; set; }
    public long Notice { get; set; }
}


